package com.bawei.mvvmzonghe.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.bawei.mvvmzonghe.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;

import androidx.databinding.BindingAdapter;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/14 10:19
 * @Description : ImageViewAdapter
 */
public class ImageViewAdapter {
    @BindingAdapter("android:image")
    public static void setImage(ImageView imageView,String url){
        if(TextUtils.isEmpty(url)){
            imageView.setImageResource(R.drawable.ic_launcher_background);
        }else{
            Glide.with(imageView)
                    .load(url)
                    .transform(new CenterCrop())
                    .into(imageView);
        }
    }
}
